package org.lboot.rbac.module.user.map;
import org.lboot.rbac.module.user.SysUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

public interface SysUserRoleDAO extends JpaRepository<SysUserRole, String> {

     List<SysUserRole> findByUserId(Long userId);

     List<SysUserRole> findByRoleId(Long roleId);

     Optional<SysUserRole> findByUserIdAndRoleId(Long userId, Long roleId);

     @Transactional
     void deleteByUserIdAndRoleId(Long userId,Long roleId);

     @Transactional
     void deleteByRoleId(Long roleId);

     @Transactional
     void deleteByRoleIdIn(List<Long> roleIds);

     @Transactional
     void deleteByUserId(Long userId);

     @Transactional
     void deleteByUserIdIn(List<Long> userIds);
}
